package com.yunxi.controller.otd;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.DictConstant;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.otd.pojo.OtdOrderScheduleQueryVO;
import com.yunxi.otd.service.OtdOrderSoDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 项目用车订单日排程 前端控制器
 * </p>
 *
 * @author XUQI
 * @since 2019-07-05
 */
@RestController
@RequestMapping("/admin/otd/project/schedule")
@Api(tags = "OTD:PROJECT_CAR_SCHEDULE", description = "项目用车订单SO日排程接口")
public class OtdProjectCarScheduleController {

    private static final Logger logger = LoggerFactory.getLogger(OtdProjectCarScheduleController.class);

    @Autowired
    OtdOrderSoDubboService otdOrderSoDubboService;


    @GetMapping("/page")
    @ApiOperation(value = "项目车订单日排程查询")
    public ApiResult page(OtdOrderScheduleQueryVO queryVO) {
        if(StringUtils.isEmpty(queryVO.getYearMonth())){
            return ResponseUtil.fail(-1, "年月不能为空");
        }
        logger.info("项目车订单日排程查询...");
        // 项目用车
        queryVO.setOrderType(DictConstant.OTD_ORDER_TYPE_PRVE);
        return ResponseUtil.ok(otdOrderSoDubboService.findSoSchedule(queryVO));
    }

    @GetMapping("/noEditDays")
    public ApiResult getNoEditDays(String yearMonth) {
        return otdOrderSoDubboService.getNoEditDays(yearMonth);
    }

}
